package com.example.ycdyus.dailyfruit.adapter;

import android.content.Context;
import android.content.Intent;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.ycdyus.dailyfruit.R;
import com.example.ycdyus.dailyfruit.bean.BaikeListBean;
import com.example.ycdyus.dailyfruit.utils.ImageLoaderHelper;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;

import org.w3c.dom.Text;

import java.util.List;

/**
 * Created by ycdyus on 2015/10/22.
 */
public class BaikeListViewAdapter extends CommonAdapter<BaikeListBean>{
    private DisplayImageOptions options;
    public BaikeListViewAdapter(Context context, List<BaikeListBean> mDatas, int itemLayoutId) {
        super(context, mDatas, itemLayoutId);
        options = ImageLoaderHelper.getDisplayImageLoader();
    }

    @Override
    public void convert(ViewHolders holder, BaikeListBean item) {
        ImageLoader.getInstance().displayImage(item.getPhoto(), (ImageView) holder.getView(R.id.iv_item_baike_img), options);
        ((TextView)holder.getView(R.id.tv_item_baike_title)).setText(item.getTitle());
        ((TextView)holder.getView(R.id.tv_item_baike_des)).setText(item.getSummary());
        int time = (item.getStime() - Integer.parseInt(item.getCtime()))/3600;
                ((TextView) holder.getView(R.id.tv_item_baike_time)).setText(time+"小时前");
        ((TextView)holder.getView(R.id.tv_item_baike_zan)).setText(item.getWorth_num());
        ((TextView)holder.getView(R.id.tv_item_baike_pinlun)).setText(item.getCollection_num());
    }
}
